//
//  UIAlertController+XLAlertView.m
//  XLBaseDemo
//
//  Created by 薛磊 on 2018/4/18.
//  Copyright © 2018年 薛磊. All rights reserved.
//

#import "UIAlertController+XLAlertView.h"

@implementation UIAlertController (XLAlertView)
+(void)xl_showAlertWithMessage:(NSString *)message isCancel:(BOOL)isCancel compentBlock:(CompentBlock)block cancelBlock:(cancelBlock)cancelBlock andViewController:(UIViewController *)viewController{
    
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        if (block) {
            block();
        }
        
    }]];
    if (isCancel) {
        [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            if (cancelBlock) {
                cancelBlock();
            }
        }]];
    }
    
    if (viewController) {
        [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
    }
    
    
}
@end
